{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "acaa6448-587f-414b-8a39-8c684a65cb20",
   "metadata": {},
   "source": [
    "# qDrift\n",
    "\n",
    "The `qdrift` function implements the qDrift Trotter evolution of Ref.[ [1] ](#qDrift).\n",
    "\n",
    "\n",
    "Function: `qdrift`\n",
    "\n",
    "Arguments:\n",
    "\n",
    "* `pauli_operator`: `CArray[PauliTerm]`,\n",
    "* `evolution_coefficient`: `CReal`,\n",
    "* `num_qdrift`: `CInt`,\n",
    "*  `qbv`: `QArray[QBit]`,"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df684532-0095-41fd-8913-b7e59d049a3b",
   "metadata": {},
   "source": [
    "## Example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dc97bd53-669a-481f-a42d-09a486046b2d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-05-07T13:24:19.013848Z",
     "iopub.status.busy": "2024-05-07T13:24:19.013096Z",
     "iopub.status.idle": "2024-05-07T13:24:23.340293Z",
     "shell.execute_reply": "2024-05-07T13:24:23.339655Z"
    }
   },
   "outputs": [],
   "source": [
    "from classiq import (\n",
    "    Output,\n",
    "    Pauli,\n",
    "    PauliTerm,\n",
    "    QArray,\n",
    "    QBit,\n",
    "    allocate,\n",
    "    create_model,\n",
    "    qdrift,\n",
    "    qfunc,\n",
    "    synthesize,\n",
    "    write_qmod,\n",
    ")\n",
    "\n",
    "\n",
    "@qfunc\n",
    "def main(qba: Output[QArray[QBit]]):\n",
    "\n",
    "    allocate(2, qba)\n",
    "    qdrift(\n",
    "        [\n",
    "            PauliTerm(pauli=[Pauli.X, Pauli.Y], coefficient=1.0),\n",
    "            PauliTerm(pauli=[Pauli.Z, Pauli.I], coefficient=0.5),\n",
    "        ],\n",
    "        evolution_coefficient=2.0,\n",
    "        num_qdrift=5,\n",
    "        qbv=qba,\n",
    "    )\n",
    "\n",
    "\n",
    "qmod = create_model(main)\n",
    "write_qmod(qmod, \"qdrift\")\n",
    "qprog = synthesize(qmod)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7e1bc3d2-fb05-4125-8bce-832d27a3a3c6",
   "metadata": {},
   "source": [
    "## References\n",
    "\n",
    "<a name=\"qDrift\">[1]</a> E. Campbell, Random Compiler for Fast Hamiltonian Simulation, (2019). [https://arxiv.org/abs/1811.08017](https://arxiv.org/abs/1811.08017)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
